﻿Imports LecturerAppointmentSystem.UserDetails


Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim userRole As String
        Dim userId As Integer = getUserId(User.Identity.Name)
        If User.IsInRole("Student") Then
            userRole = "Student"
        ElseIf User.IsInRole("Lecturer") Then
            userRole = "Lecturer"
        ElseIf User.IsInRole("Administrator") Then
            userRole = "Administrator"
        Else
            userRole = ""
        End If
        Dim userDetails As ListDictionary = New ListDictionary()
        userDetails.Add("username", User.Identity.Name)
        userDetails.Add("userid", getUserId(User.Identity.Name))
        userDetails.Add("university", getUserUniversity(userId, userRole))
        Session("UserDetails") = userDetails
        Session("University") = getUserUniversity(userId, userRole)
        If Roles.IsUserInRole("Lecturer") Then
            Response.Redirect("Calendar.aspx?Date=" & Date.Today & ("&UserId=" & userDetails.Item("userid")))
        ElseIf Roles.IsUserInRole("Student") Then
            Response.Redirect("Calendar.aspx?Date=" & Date.Today & ("&UserId=" & userDetails.Item("userid")))
        ElseIf Roles.IsUserInRole("Administrator") Then
            Response.Redirect("AdministratorHome.aspx")
        Else
            Response.Redirect("Login.aspx")
        End If
    End Sub
End Class